using System;
using System.Collections.Generic;
using System.Text;
using LeisureCenter.Api;
using LeisureCenter.Core;

namespace LeisureCenter.Playlist
{
    public class VideoDvdPlaylistItem : BasePlaylistItem
    {
        public VideoDvdPlaylistItem(VideoDvdPlaylist playlist)
            : base(playlist)
        {
            _media = ((VideoDvdPlaylist)playlist).videoDvdMedia;
        }

        protected override void CreateMedia()
        {
        }

        public override string Text
        {
            get { return ((IVideoDvdMedia)this._media).GetTitle(this.Index); }
        }
    }

    public class VideoDvdPlaylist : BasePlaylist
    {
        internal IVideoDvdMedia videoDvdMedia;

        public VideoDvdPlaylist(PlaylistManager playlistManager, string path)
            : base(playlistManager)
        {
            videoDvdMedia = (IVideoDvdMedia)Program.LeisureCenterInstance.PlayersManager.VideoDvdPlayer.CreateMedia(path, MediaKind.DVD);
            //foreach (string title in audioCdMedia.Titles)
            //{
            //    this.items.Add(new AudioCdPlaylistItem(this));
            //}
            //audioCdMedia.PlaylistChanged += new EventHandler(audioCdMedia_PlaylistChanged);
            //audioCdMedia.MediaEnded += new EventHandler(audioCdMedia_MediaEnded);
            this.items.Add(new VideoDvdPlaylistItem(this));
        }

        protected internal override void playlistManager_PlayModeChanged(object sender, EventArgs e)
        {
        }

        public override void Previous()
        {
            this.videoDvdMedia.Previous();
        }

        public override void Next()
        {
            if (activePlaylistItem != null)
                this.videoDvdMedia.Next();
            else
            {
                ActivePlaylistItem = this.items[0];
                ActivePlaylistItem.Play();
            }
        }

        public override int ActivePlaylistItemIndex
        {
            get
            {
                return 0;
            }
            set
            {
            }
        }
    }
}
